{	Problem: http://codeforces.ru/problemset/problem/32/A
 	Verdict: Accepted
}
var i,j,r,n,d:longint; a:array[1..1010] of longint;
begin
read(n,d);
r:=0;
for i:=1 to n do read(a[i]);
for i:=1 to n do
  for j:=1 to n do
    if (i<>j) and (abs(a[i]-a[j])<=d) then inc(r);
write(r);
end.